#pragma warning(disable:6031)//取消VS编译器的一个警告
#include "LinkList.h" //引用头文件

int main() {
	//构造并初始化一个空表
	printf("创建一个学籍链表\n");
	SL stulist;
	InitList(&stulist);
	//创建首元结点并链接到头指针
	Student stu1 = { 10246,"张三","男" };
	SL stu_l1 = (SL)malloc(sizeof(Stu_List));
	if (stu_l1 == NULL) printf("创建首元结点失败\n");
	else {
		stu_l1->Data = stu1;
		stu_l1->next = NULL;
		stulist->next = stu_l1;
		printf("将张三录入学籍链表\n");
	}
	//取首元结点的值
	Student getdata;
	int num = 1;
	num = GetList(stulist,num,&getdata);
	printf("学籍表中第一个学生是%s\n", getdata.name);
	//按数值查找
	num = Locate_Value(stulist, "张三");
	printf("寻找张三，他在链表第%d个位置\n", num);
	//按地址查找
	int address = 1;
	char  locate_name[10] = {0};
	Locate_Address(stulist,address,locate_name);
	printf("寻找第%d个链表，他是%s\n", address,locate_name);
	//插入数据元素
	//首先有一条data
	Student stu2 = { 35415,"李四","保密"};
	//将这个data插入到链表位置
	int insert_num = 2;
	Insert_List(stulist, insert_num, stu2);
	//删除数据元素
	int delnum = 1;
	Student delstu = {0};
	Del_List(stulist, delnum,&delstu);
	printf("被删除的是%s\n", delstu.name);
	//清空链表
	Clean_List(stulist);
	if (stulist->next == NULL) printf("链表被清空了\n");
	else printf("链表没被清空\n");

	//链表持续录入：前插法
	num = 3;
	EnterList_H(stulist, num);
	//printf("链表第一名学生是：%s\n", stulist->next->Data.name);//仅为测试使用，这样取值有空指针隐患
	//printf("链表第二名学生是：%s\n", stulist->next->next->Data.name);
	//printf("链表第三名学生是：%s\n", stulist->next->next->next->Data.name);
	//链表持续录入：后插法
	EnterList_R(stulist, num);
	//printf("链表第一名学生是：%s\n", stulist->next->Data.name);//仅为测试使用，这样取值有空指针隐患
	//printf("链表第二名学生是：%s\n", stulist->next->next->Data.name);
	//printf("链表第三名学生是：%s\n", stulist->next->next->next->Data.name);

	return 0;
}